package com.draem0507.refactor;

import java.util.Date;

/**
 * @title 封装条件
 * @desc
 * @atuh lwx
 * @createtime on 2015/11/14 13:24
 */
public class Day_16 {





    public class RemoteControl2 {
        private String[] Functions;
        private String Name;
        private int CreatedYear;

        public String PerformCoolFunction(String buttonPressed) {
            // Determine if we are controlling some extra function
            // that requires special conditions
            if (HasExtraFunctions()) {
                return "doSomething";

            }
            return "";
        }

        private boolean HasExtraFunctions()
        {
           return Functions.length > 1 && Name == "RCA" && CreatedYear > new Date().getYear() - 2 ;
        }


    }



    public class RemoteControl {
        private String[] Functions;
        private String Name;
        private int CreatedYear;

        public String PerformCoolFunction(String buttonPressed) {
            // Determine if we are controlling some extra function
            // that requires special conditions
            if (Functions.length > 1 && Name == "RCA" && CreatedYear > new Date().getYear() - 2) {
                return "doSomething";

            }
            return "";
        }
    }

}
